package org.quarenden.demo.controller;

import org.quarenden.demo.dao.SequenceRepository;
import org.quarenden.demo.sequence.GlobalSequenceIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SequenceController {

    @GetMapping("/{idType}")
    public String getSequence(@PathVariable String idType){
        if("seq1".equals(idType)){
            return GlobalSequenceIdProvider.seq1NextVal();
        }else if("seq2".equals(idType)){
            return GlobalSequenceIdProvider.seq2NextVal();
        }else{
            return null;
        }
    }

    @PostMapping("/post/{idType}")
    public String getSequencePost(@PathVariable String idType){
        if("seq1".equals(idType)){
            return GlobalSequenceIdProvider.seq1NextVal();
        }else if("seq2".equals(idType)){
            return GlobalSequenceIdProvider.seq2NextVal();
        }else{
            return null;
        }
    }

}
